![]() |
Kinetis SDK Demo Applications User Guide
1.0.0-beta
Freescale Semiconductor, Inc.
|
#include "fsl_gpio_hal.h"#include "i2c_sim.h"#include "fsl_os_abstraction.h"#include "fsl_clock_manager.h"Macros | |
| #define | I2C_INIT |
| #define | I2C_ACTIVE |
| #define | I2C_TRISTATE |
| #define | I2C_READ |
| #define | I2C_SDA_DIR(dir) |
| #define | I2C_SDA(bit) |
| #define | I2C_SCL(bit) |
| #define | I2C_DELAY |
| #define | RETRIES |
| #define | I2C_ACK |
| #define | I2C_NOACK |
| #define | PRINTD(fmt, args...) |
Functions | |
| static void | send_start (void) |
| Send START. More... | |
| static void | send_stop (void) |
| Send STOP. More... | |
| static void | send_ack (int32_t ack) |
| Send ACK. More... | |
| static int32_t | write_byte (uint8_t data) |
| Send 8 bits and look for an acknowledgement. More... | |
| static uint8_t | read_byte (int32_t ack) |
| Read one byte. More... | |
| void | i2c_gpio_init (int32_t speed, int32_t slaveaddr) |
| Initialization. More... | |
| uint8_t | i2c_gpio_probe (uint8_t addr) |
| Probe to see if a chip is present. Probe to see if a chip is present. Also good for checking for the completion of EEPROM writes since the chip stops responding until the write completes (typically 10mSec). More... | |
| uint8_t | i2c_gpio_read (uint8_t chip, uint32_t addr, int32_t alen, uint8_t *buffer, int32_t len) |
| Read bytes. More... | |
| uint8_t | i2c_gpio_write (uint8_t chip, uint32_t addr, int32_t alen, uint8_t *buffer, int32_t len) |
| Write bytes. More... | |
| #define I2C_ACK |
| #define I2C_ACTIVE |
| #define I2C_DELAY |
| #define I2C_INIT |
| #define I2C_NOACK |
| #define I2C_READ |
| #define I2C_SCL | ( | bit | ) |
| #define I2C_SDA | ( | bit | ) |
| #define I2C_SDA_DIR | ( | dir | ) |
| #define I2C_TRISTATE |
| #define PRINTD | ( | fmt, | |
| args... | |||
| ) |
| #define RETRIES |
| void i2c_gpio_init | ( | int32_t | speed, |
| int32_t | slaveaddr | ||
| ) |
| [in] | speed | I2C speed. |
| [in] | slaveaddr | Slave device address. |
| uint8_t i2c_gpio_probe | ( | uint8_t | addr | ) |
| [in] | addr | I2C slave device address. |
| uint8_t i2c_gpio_read | ( | uint8_t | chip, |
| uint32_t | addr, | ||
| int32_t | alen, | ||
| uint8_t * | buffer, | ||
| int32_t | len | ||
| ) |
This function will read data from i2c slave device.
| [in] | chip | Chip number. |
| [in] | addr | Address in I2C slave device. |
| [in] | alen | Address len. |
| [in] | buffer | Buffer address that will be read to. |
| [in] | len | Len of data that will be read. |
| uint8_t i2c_gpio_write | ( | uint8_t | chip, |
| uint32_t | addr, | ||
| int32_t | alen, | ||
| uint8_t * | buffer, | ||
| int32_t | len | ||
| ) |
This function will write data to i2c slave device.
| [in] | chip | Chip address. |
| [in] | addr | Address in I2C slave device. |
| [in] | alen | Address len. |
| [in] | buffer | Buffer address that will be write. |
| [in] | len | Len of data that will be write. |
|
static |
if ack == I2C_ACK, ACK the byte so can continue reading, else send I2C_NOACK to end the read.
| [in] | ack | Ack data that to be sent. |
|
static |
Send ACK. Ack should be I2C_ACK or I2C_NOACK.
|
static |
Send START. High -> Low on SDA while SCL is High.
|
static |
Send STOP. STOP: Low -> High on SDA while SCL is High.
|
static |
| [in] | data | Data that will be write. |